<template>
	<view class="containetr">
		<image src="@/static/images/logo.png" mode="widthFix" class="logo"></image>
		<view class="content">
			<!-- #ifdef MP -->
			<button class="button" open-type="getuserInfo" bindgetuserinfo="getloginid"
				@click="getloginid">微信授权快速登录</button>
			<!-- #endif -->
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				wxInfo: null,
				code: '',
				spread_code: '',
				spread_spid: ''
			}
		},
		onLoad(opdata) {
			this.spread_spid = opdata.spread_spid
			this.spread_code = opdata.spread_code
			this.wxLogin()
		},
		methods: {
			wxLogin() {

			},
			getloginid() {
				console.log(123);
				// #ifdef MP
				wx.login({
					success: logres => {
						wx.getUserInfo({
							withCredentials: true,
							success: res => {
								let data = {}
								data = {
									code: logres.code,
									spread_code: this.spread_code,
									spread_spid: this.spread_spid,
									...res
								}
								this.$allApi.login(data).then(ress => {
									this.$u.toast('登录成功')
									uni.setStorageSync('userInfo', ress.data.userInfo)
									uni.setStorageSync('userToken', ress.data.token)
									setTimeout(() => {
										this.$backTo()
									}, 1500)
								})
							}
						})
					}
				})
				// #endif
			},
		}
	}
</script>
<style scoped lang="scss">
	.content {
		margin-top: 20vh;
	}

	.button {
		width: 710rpx;
		height: 88rpx;
		background: #EA3D37;
		border-radius: 10rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		color: #fff;
		margin: 0 auto;
		margin-top: 60rpx;
	}

	.logo {
		width: 260rpx;
		height: 260rpx;
		margin-left: 245rpx;
	}

	.containetr {
		min-height: 100vh;
		background: #fff;
		padding-top: 80rpx;
	}
</style>